<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  // getLogisticsStatus('SF-20230217-000001');
  // 输出：{ company: 'SF', date: '20230217', serialNumber: '000001' }

  // getLogisticsStatus('YTO-20230217-000002');
  // 输出：{ company: 'YTO', date: '20230217', serialNumber: '000002' }

  getLogisticsStatus('SF-20230217-000003-TEST');
  // // 输出：null

  // getLogisticsStatus('SF-20230217');
  // // 输出：null

  // getLogisticsStatus('SF-20230217000004');
  // 输出：null

  function getLogisticsStatus(arr) {
    let arr1 = arr.split('-')
    console.log(arr1[1].length)
    if (arr1.length !== 3) {
      return null
    } else {
      if (arr1[1].length > 8) {
        return
      } else {
        let a = arr[0]
        let b = arr[1]
        let c = arr1[2]
        let obj = { a, b, c }
        if (obj.a.trim() == '' || obj.b.trim() == '' || obj.c.trim() == '') {
          return obj
        }
      }
    }
  }
</script>

</html>